package com.citicpub_cloud.restfull.dao;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.citicpub_cloud.restfull.api.dto.TbAdminAccountExt;
import com.citicpub_cloud.restfull.dao.jdbc.AbstractJdbcDaoSupport;
import com.citicpub_cloud.restfull.dao.mapper.TbAdminAccountExtMapper;

@Service
public class AdminAccountDaoService extends AbstractJdbcDaoSupport {
   public List<TbAdminAccountExt> selectByLoginName(String loginName) {
	   List<TbAdminAccountExt> list = new ArrayList<TbAdminAccountExt>();
	   try{
		   String sql = "select a.*,u.password from tb_admin_account a "
				   + "LEFT JOIN tb_user_info u on a.uid = u.uid "
				   + "where a.login_name = '" + loginName + "' "
				   + "and a.is_deleted = false and u.status = 1";
		   
		   list = jdbcTemplate.query(sql, new TbAdminAccountExtMapper());
		} catch (Exception e) {
			log.error("根据登录名查找账户列表出错", e);			
		}		
		return list;
   }
}
